package com.lovegu.book.concurrence;

import java.lang.management.ManagementFactory;
import java.lang.management.ThreadInfo;
import java.lang.management.ThreadMXBean;

/**
 * @author 老顾
 * @title: ThreadPrint
 * @projectName java-restudy
 * @email: 1437594522@qq.com
 * @date 2022/11/5 8:45
 */
public class ThreadPrint {
    public static void main(String[] args) throws InterruptedException {
        ThreadMXBean threadMXBean = ManagementFactory.getThreadMXBean();
        ThreadInfo[] threadInfos = threadMXBean.dumpAllThreads(false,false);
        for (ThreadInfo threadInfo : threadInfos) {
            System.out.println("["+threadInfo.getThreadId()+"]"+threadInfo.getThreadName());
        }
        Thread.sleep(1000000);
    }
}
